<?php

include_once(dirname(__FILE__) . "../../_DATABASE_DAO/LookupsDAO.class.php");
include_once(dirname(__FILE__) . "../../_DATABASE_DAO/GenericDAO.class.php");
$genericDAO = new GenericDAO();
if ($_REQUEST['action'] == 'view') {
    $datas = $genericDAO->listAll("sponsor");
    include('views/sponsor/home.php');
    exit;
}

if ($_REQUEST['action'] == 'viewMore') {
    if(isset($_REQUEST['id']))
    $data = $genericDAO->get("sponsor",$_REQUEST['id']);
    $data->interestedQuestions = $genericDAO->listAllWhere("sponsorQuestion", " sponsorId = ".$data->id);
        foreach($data->interestedQuestions as $temp)
        {
            $temp->interestedQuestion=$genericDAO->get("interestedQuestion", $temp->interestQuestionId);
        }
        
    $data->sponsorPrivilegess = $genericDAO->listAllWhere("sponsorPrivileges", "sponsorId = ".$data->id);
        foreach($data->sponsorPrivilegess as $temp)
        {
            $temp->sponsorPrivileges=$genericDAO->get("privileges", $temp->privilegeId);
            $temp->sponsorPrivileges->type=$genericDAO->get("privilegesType", $temp->sponsorPrivileges->typeId);
        }
    include ("views/sponsor/viewMore.php");
    exit;
}
?>
